#import "PIIntegration.h"


@implementation PIIntegration

+(NSString*) iconFileForAction:(int)action
{
	NSString* actionIcon = nil;
	
	switch (action) {
		case PIActionNext:
			actionIcon = @"NextAction";
			break;
		case PIActionActive:
			actionIcon = @"Active";
			break;
		case PIActionPlanning:
			actionIcon = @"Planning";
			break;
		case PIActionDelegated:
			actionIcon = @"Delegated";
			break;
		case PIActionWaiting:
			actionIcon = @"Waiting";
			break;
		case PIActionHold:
			actionIcon = @"Hold";
			break;
		case PIActionPostponed:
			actionIcon = @"Postponed";
			break;
		case PIActionSomeday:
			actionIcon = @"Someday";
			break;
		case PIActionCancelled:
			actionIcon = @"Cancelled";
			break;
		case PIActionReference:
			actionIcon = @"Reference";
			break;
		default:
			actionIcon = nil;
			break;
	}
	
	return actionIcon;
}

+(UIColor*) topImportanceBGColorForPrefs:(NSDictionary*)prefs
{
	// Top importance color
	NSArray* piTop = [prefs valueForKey:@"PICalPriorityColor_1_background"];
	if (piTop != nil)
		return [UIColor colorWithRed:[[piTop objectAtIndex:0] doubleValue] 
							   green:[[piTop objectAtIndex:1] doubleValue]
								blue:[[piTop objectAtIndex:2] doubleValue]
							   alpha:[[piTop objectAtIndex:3] doubleValue]];
	else
		return [UIColor colorWithRed:1 
							   green:0
								blue:0
							   alpha:1];
}

+(UIColor*) highImportanceBGColorForPrefs:(NSDictionary*)prefs
{
	// High importance color	
	NSArray* piHigh = [prefs valueForKey:@"PICalPriorityColor_5_background"];
	if (piHigh != nil)
		return [UIColor colorWithRed:[[piHigh objectAtIndex:0] doubleValue] 
							   green:[[piHigh objectAtIndex:1] doubleValue]
								blue:[[piHigh objectAtIndex:2] doubleValue]
							   alpha:[[piHigh objectAtIndex:3] doubleValue]];
	else 
		return [UIColor colorWithRed:1 
							   green:0.4980392156862745
								blue:0
							   alpha:1];
}

+(UIColor*) normalImportanceBGColorForPrefs:(NSDictionary*)prefs
{
	// Normal importance color
	NSArray* piNormal = [prefs valueForKey:@"PICalPriorityColor_10_background"];
	if (piNormal != nil)
		return [UIColor colorWithRed:[[piNormal objectAtIndex:0] doubleValue] 
							   green:[[piNormal objectAtIndex:1] doubleValue]
								blue:[[piNormal objectAtIndex:2] doubleValue]
							   alpha:[[piNormal objectAtIndex:3] doubleValue]];
	else 
		return [UIColor colorWithRed:0
							   green:1
								blue:0
							   alpha:1];
}

+(UIColor*) lowImportanceBGColorForPrefs:(NSDictionary*)prefs
{
	// Low importance color
	NSArray* piLow = [prefs valueForKey:@"PICalPriorityColor_15_background"];
	if (piLow != nil)
		return [UIColor colorWithRed:[[piLow objectAtIndex:0] doubleValue] 
							   green:[[piLow objectAtIndex:1] doubleValue]
								blue:[[piLow objectAtIndex:2] doubleValue]
							   alpha:[[piLow objectAtIndex:3] doubleValue]];
	else 
		return [UIColor colorWithRed:0
							   green:1
								blue:1
							   alpha:1];
}

+(UIColor*) overdueBGColorForPrefs:(NSDictionary*)prefs
{
	// Overdue color
	NSArray* piOverdue = [prefs valueForKey:@"PIColorTaskOverdue"];
	if (piOverdue != nil)
		return [UIColor colorWithRed:[[piOverdue objectAtIndex:0] doubleValue] 
							   green:[[piOverdue objectAtIndex:1] doubleValue]
								blue:[[piOverdue objectAtIndex:2] doubleValue]
							   alpha:[[piOverdue objectAtIndex:3] doubleValue]];
	else
		return [UIColor colorWithRed:1
							   green:0.4470588235294118
								blue:0.4470588235294118
							   alpha:1];	
}

@end
